package com.guet.main.service.impl;

import com.alibaba.excel.EasyExcel;
import com.guet.main.Listener.UserListener;
import com.guet.main.entity.User;
import com.guet.main.entity.vo.UserVo;
import com.guet.main.mapper.UserMapper;
import com.guet.main.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;

/**
 * <p>
 * user 服务实现类
 * </p>
 *
 * @author csp
 * @since 2022-07-29
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public void saveSubject(MultipartFile file, UserService userService) {
        try {
            //得到文件的输入流
            InputStream in = file.getInputStream();
            //调用方法进行读取
            EasyExcel.read(in, UserVo.class, new UserListener(userService)).sheet().doRead();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
